<?php

/**
 * EmsFormField form base class.
 *
 * @method EmsFormField getObject() Returns the current form's model object
 *
 * @package    ems1
 * @subpackage form
 * @author     Jacobo Martínez
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseEmsFormFieldForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'            => new sfWidgetFormInputHidden(),
      'title'         => new sfWidgetFormInputText(),
      'is_key'        => new sfWidgetFormInputCheckbox(),
      'is_unique'     => new sfWidgetFormInputCheckbox(),
      'is_required'   => new sfWidgetFormInputCheckbox(),
      'field_type_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('FieldType'), 'add_empty' => false)),
      'options'       => new sfWidgetFormInputText(),
      'is_enabled'    => new sfWidgetFormInputCheckbox(),
      'form_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Form'), 'add_empty' => false)),
      'created_at'    => new sfWidgetFormDateTime(),
      'updated_at'    => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'            => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'title'         => new sfValidatorString(array('max_length' => 100)),
      'is_key'        => new sfValidatorBoolean(array('required' => false)),
      'is_unique'     => new sfValidatorBoolean(array('required' => false)),
      'is_required'   => new sfValidatorBoolean(array('required' => false)),
      'field_type_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('FieldType'))),
      'options'       => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'is_enabled'    => new sfValidatorBoolean(array('required' => false)),
      'form_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Form'))),
      'created_at'    => new sfValidatorDateTime(),
      'updated_at'    => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('ems_form_field[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'EmsFormField';
  }

}
